#ifndef MOSES_FUNCTION_H
#define MOSES_FUNCTION_H

#include "Item.h"
#include "ItemList.h"
#include "Value.h"

namespace moses
{
	class Identifier;
	class Expr;
	class Runtime;
	class Pattern;
	
	class FunctionRow : public Item
	{
	public:
		MOSES_ITEM_VISITABLE()
		
		FunctionRow(		Identifier *pIdentifier,
							ItemList<Pattern> *pPatternList,
							Expr *pExpr);
		
		bool				MatchesArgs(Runtime *pEnv, ItemList<Expr> *pArgs);
		
		
		Identifier*			GetIdentifier();
		ItemList<Pattern>*	GetPatternList();
		Expr*				GetExpr();
		
	private:
		Identifier			*m_pIdentifier;
		ItemList<Pattern>	*m_pPatternList;
		Expr				*m_pExpr;
	};
	
	class Function : public Item
	{
	public:
		MOSES_ITEM_VISITABLE()
		
		Function(				Identifier *pIdentifier,
								ItemList<Type> *pParams,
								ItemList<FunctionRow> *pRows);
		
		Identifier*				GetIdentifier();	
		ItemList<Type>*			GetParameters();
		ItemList<FunctionRow>*	GetRows();
		
		Value					Call(Runtime *pEnv, ItemList<Expr> *pArgs);
		
	private:
		Identifier				*m_pIdentifier;
		ItemList<Type>			*m_pParams;
		ItemList<FunctionRow>	*m_pRows;
		
	};	
}

#endif